<template>
    <div>
        <h1>登录界面</h1>
        <table class="table" border="1">
            <tr>
                <td>用户名</td>
                <td><input type="text" v-model="userName"/></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password" v-model="password"/></td>
            </tr>
            <tr>
                <td colspan="2"><button class="btn btn-primary" @click="login">登录</button></td>
            </tr>
        </table>
    </div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';
const router = useRouter();

const userName = ref('');
const password = ref('');

const login = () => {
    if(userName.value==''||password.value==''){
        alert('用户名或密码不能为空');
        return;
    }
    if(userName.value=='Admin123'&&password.value=='Admin123'){
        router.push('/Loginall');
    }else{
        alert('用户名或密码错误');
    }
};
</script>